package org.tio.sitexxx.im.server.timetask;

import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tio.sitexxx.im.server.Ims;
import org.tio.sitexxx.service.vo.Const;
import org.tio.sitexxx.service.vo.LoadData;
import org.tio.utils.json.Json;
import org.tio.utils.quartz.AbstractJobWithLog;
import org.tio.utils.zk.Zk;

/**
 *  上报负载数据
 * @author tanyaowu 
 * 2016年10月8日 下午2:28:11
 */
public class ReportLoadJob extends AbstractJobWithLog {
	private static Logger log = LoggerFactory.getLogger(ReportLoadJob.class);

	@Override
	public void run(JobExecutionContext context) throws Exception {
		boolean startIm = true;//P.getInt("start.im", 2) == 1;
		if (!startIm) {
			return;
		}
		LoadData loadData = Ims.createLoadData();
		String myip = org.tio.sitexxx.service.vo.Const.SERVICE_HOST;
		String path = Const.ZkNode.IM_SERVERS + "/" + myip;

		try {
			Zk.setData(path, Json.toJson(loadData));
		} catch (Exception e) {
			log.error(e.toString(), e);
		}

		//		String data = Zk.getString(path);
	}
}
